{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Solution(object):\n",
    "    def addStrings(self, num1, num2):\n",
    "        \"\"\"\n",
    "        :type num1: str\n",
    "        :type num2: str\n",
    "        :rtype: str\n",
    "        \"\"\"\n",
    "        len1 = len(num1)\n",
    "        len2 = len(num2)\n",
    "        \n",
    "        if len1 < len2:\n",
    "            num1 = '0' * (len2 - len1) + num1\n",
    "            length = len2\n",
    "        else:\n",
    "            num2 = '0' * (len1 - len2) + num2\n",
    "            length = len1\n",
    "            \n",
    "        s = ''\n",
    "        carry = 0\n",
    "        for i in range(length):\n",
    "            id = -(i+1)\n",
    "            cur = int(num1[id]) + int(num2[id]) + carry\n",
    "            s = str(cur % 10) + s\n",
    "            carry = cur // 10\n",
    "\n",
    "        if carry > 0:\n",
    "            s = str(carry) + s\n",
    "            \n",
    "        return s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = Solution()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'100000010'"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.addStrings('100000000', '10')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
